<!DOCTYPE html>
<!-- saved from url=(0095)http://localhost:52330/c:/Users/Administrator/Desktop/%E6%8A%BD%E5%A5%96%E7%B3%BB%E7%BB%9F.html -->
<html lang="en">

<head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简易抽奖器╮(￣▽ ￣)╭</title>
    <link rel="stylesheet" type="text/css" href="styles.css">

    <style>
        #version {
            position: absolute;
            font-size: 12px;

        }

        #v12 {
            color: #000000;
            text-decoration: none;
        }

        #v12:hover {
            color: #007bff;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #FFFFFF;
            font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
            text-align: center;
            padding: 10px;

        }

        #container {
            padding: 20px;
            background-color: #fff;
            border: 2px solid #007bff;
            border-radius: 10px;
            box-shadow: 0 0 10px #007bff;
        }



        h1 {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 10px;
        }

        #nameList {
            width: 80%;

            padding: 10px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 5px;
            resize: vertical;
            /* 允许垂直调整大小 */
        }

        input[type="number"],
        input[type="text"],
        button {

            overflow: auto;
            width: 90%;
            padding: 10px;
            margin-bottom: 10px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-shadow: 2px 2px 5px #007bff;
            transition: transform 0.3s;
            /* 添加按钮滚动变换效果 */
        }

        button {
            background-color: #007bff;
            color: #fff;
            border: none;
            cursor: pointer;

        }

        button:hover {
            background-color: #0056b3;
            transform: scale(1.05);
            /* 鼠标悬停时按钮放大 */
        }

        label[for="numOfWinners"] {
            text-align: left;
            font-family: Arial, sans-serif;
            /* 设置字体 */
            color: #007bff;
            /* 设置颜色 */
            font-size: 16px;
            /* 设置字体大小 */
        }

        label[id="11"] {
            text-align: left;
            font-family: Arial, sans-serif;
            /* 设置字体 */
            color: #007bff;
            /* 设置颜色 */
            font-size: 16px;
            /* 设置字体大小 */
        }
       
        #resultList {
            resize: both;
            overflow: auto;
            list-style: none;
            padding: 10px;
            text-align: center;
            margin: 20px auto;
            /* Updated margin to auto */
            width: 80%;
            /* Added width to control the size of the box */
            border: 1px solid #ccc;
            border-radius: 5px;
            background-color: #fff;
            box-shadow: 2px 2px 5px #007bff;
        }

        #resultList li {
            margin-bottom: 5px;
        }

        #winnerDisplay {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            padding: 20px;
            background-color: #fff;
            border-radius: 10px;
            box-shadow: 0 0 20px #FFD700;
            z-index: 999;
            animation: changeColor 2s infinite alternate;
            font-weight: bold;
        }

        .selection-module label {
            display: block;

            margin-bottom: 10px;
            font-size: 18px;
            margin-right: 15px;
            line-height: 32px;
        }

        .selection-module input {
            appearance: none;

            border-radius: 50%;
            width: 16px;
            height: 16px;

            border: 2px solid #999;
            transition: 0.2s all linear;
            margin-right: 5px;

            position: relative;
            top: 4px;
        }

        .selection-module input:checked {
            border: 6px solid #007bff;
        }

        @keyframes changeColor {
            0% {
                background-color: #ffd700;
            }

            25% {
                background-color: #ffed00;
            }

            50% {
                background-color: #ecd453;
            }

            75% {
                background-color: #ffbf00;
            }

            100% {
                background-color: #ffcc00;
            }
        }

        .foot_bg {
            font-size: 14px;
            width: 100%;
            margin: 0 auto;
            background: #4d9ef4;
            border: 2px solid #66a7ec;
            border-radius: 10px;
        }

        .foot {
            width: 100%;
            margin: 0 auto;

        }

        .foot_p {

            color: #FFFFFF;
        }

        .foot_p a {
            color: #FFFFFF;
        }

        .foot_p a:hover {
            color: #000000;
        }
    </style>



</head>

<body>
  
    <div id="container">

        <h1>简易抽奖器≧▽≦y</h1>
        <div class="selection-module">
            <label for="autoGenerate">自动生成抽奖成员模式<input type="radio" id="autoGenerate" name="selection"
                    onchange="showInputNum()"></label>

            <label for="manualInput">手动输入抽奖成员模式<input type="radio" id="manualInput" name="selection"
                    onchange="showInputNames()"></label>
            <label>幸运转盘抽签抽奖模式<input type="radio" name="selection" onchange="showmode3()"></label>


        </div>
        <div id="Mode3" style="display: none;">
            <div class="box">
                <div class="main" ontransitionend="end()">
                    <div id="temp" class="part" style="display: none;">
                        <div class="bg"></div>
                        <div class="title"></div>
                    </div>
                </div>

                <div class="pointer">
                    <div class="pointer-bar"></div>
                    <div class="pointer-cursor"></div>
                </div>
            </div>
           
            <button onclick="start()">开始</button>
            <audio controls="controls" height="100" width="100" autoplay loop>
                <source src="巴黎世家2.0.wav" type="audio/mp3" />
                <source src="巴黎世家2.0.wav" type="audio/ogg" />
              <embed height="100" width="100" autoplay loop src="巴黎世家2.0.wav" />
              </audio>
            
            <script type="text/javascript" src="script.js"></script>
        </div>
       


        <div id="inputNum" style="display: none;">
            <label for="numOfNames" id="11"><br>&nbsp;&nbsp;&nbsp;&nbsp;请输入参与抽奖的人数：</label>
            <input type="number" id="numOfNames" placeholder="点击版本号10次有彩蛋(⊙o⊙)！">
            <button onclick="autoGenerateNames()">生成名单</button>
        </div>

        <div id="inputNames" style="display: none;">
            <label for="nameList" id="11"><br>&nbsp;&nbsp;&nbsp;&nbsp;请输入全部参与者姓名：</label>
            <textarea id="nameList" rows="4"
                placeholder="姓名之间，请宝宝用空格或换行隔开₍ᐢ..ᐢ₎♡ &nbsp;&nbsp;&nbsp;（wjh520/wjh1314）"></textarea>
            <button onclick="generateFromInput()">确定名单</button>
        </div>

        <div id="result" style="display: none;">
            <h2>参与抽奖者名单：</h2>
            <ul id="resultList"></ul>
            <label for="numOfWinners">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请定义获奖人数：</label>
            <input type="number" id="numOfWinners">
            <button onclick="startLottery()">开始滚动吧｀（*∩_∩*）′</button>
        </div>

        <div id="winnerDisplay">

            <h2>&nbsp;恭喜中奖(ᕑᗢᓫ∗)</h2>
            <p id="winnerName"></p>
            <button onclick="closeWinnerDisplay()">关闭</button>
        </div>
        <br>
        <div class="foot_bg">
            <div class="foot">
                <div class="foot_p">
                    <p style="text-align: center; font-family:楷体">版权所有<a
                            href="https://gitee.com/ZJCACE/zjcace">©Chengpp-ZJCSpace</a>
                    <p style="text-align: center; font-family:楷体">技术支持:
                        <a style="font-family:楷体" href="联系方式.HTML">Chengpp</a>
                        <a style="font-family:楷体" href="联系方式.HTML">联系我们</a>
                        <a style="font-family:楷体" href="联系方式.HTML">意见建议</a>
                    </p>
                    </p>
                </div>
            </div>
        </div>
        <span id="version">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;版本号:<a onclick="CheatSet()" href="#" id="v12">1.358b(测试版)</a></span>
           
</body>


<script>
    var inputName = '';
    var cheatCode = '';
    var cheatMode = false;
    var clickCount = 0;
    var cheatName = 1;



    function showInputNum() {
        document.getElementById('inputNum').style.display = 'block';
        document.getElementById('inputNames').style.display = 'none';
        document.getElementById('result').style.display = 'none';
        document.getElementById('Mode3').style.display = 'none';
    }

    function showInputNames() {
        document.getElementById('inputNum').style.display = 'none';
        document.getElementById('inputNames').style.display = 'block';
        document.getElementById('result').style.display = 'none';
        document.getElementById('Mode3').style.display = 'none';
    }
    function showmode3() {
        document.getElementById('inputNum').style.display = 'none';
        document.getElementById('inputNames').style.display = 'none';
        document.getElementById('result').style.display = 'none';
        document.getElementById('Mode3').style.display = 'block';
    }
    function CheatSet() {
        clickCount++;
        if (clickCount === 10) {

            cheatCode = prompt('请输入作弊码：');
            if (cheatCode === 'wjh1314') {
                alert("Success！");
                var flag = 0;
                cheatMode = true;
                inputName = prompt('请输入希望不会中奖者姓名(目前仅支持1人)：');
                var nameListElement = document.getElementById('resultList');
                var numOfNames = nameListElement.children.length;
                var names = [];
                for (var i = 0; i < nameListElement.children.length; i++) {
                    names.push(nameListElement.children[i].textContent);
                }

                for (var i = 0; i < nameListElement.children.length; i++) {
                    if (names[i] === inputName) {
                        alert(inputName + "将无缘中奖！");
                        cheatName = i;
                        var flag = 1;
                        break;
                    }
                }
                if (flag === 0) {
                    alert("未找到到对应姓名,请重新进入作弊程序，再次输入！");
                    cheatMode = false;
                    clickCount = 0;

                }

            }
            else if (cheatCode === 'wjh520') {
                alert("Success！");
                var flag = 0;
                cheatMode = true;
                inputName = prompt('请输入100%中奖人的姓名（目前仅支持1人）：');
                var nameListElement = document.getElementById('resultList');
                var numOfNames = nameListElement.children.length;
                var names = [];
                for (var i = 0; i < nameListElement.children.length; i++) {
                    names.push(nameListElement.children[i].textContent);
                }

                for (var i = 0; i < nameListElement.children.length; i++) {
                    if (names[i] === inputName) {
                        alert(inputName + "将100%中奖！");
                        cheatName = i;
                        var flag = 1;
                        break;
                    }
                }
                if (flag === 0) {
                    alert("未找到到对应姓名,请重新进入作弊程序，再次输入！");
                    cheatMode = false;
                    clickCount = 0;

                }
            }
            else {
                alert('作弊码错误！');
                cheatMode = false;
                clickCount = 0;
            }
        }
        else if (clickCount === 20) {
            alert('已成功退出作弊模式！');
            cheatMode = false;
            clickCount = 0;
        }

    }

    function autoGenerateNames() {
        var numOfNames = document.getElementById('numOfNames').value;
        var names = '';
        for (var i = 1; i <= numOfNames; i++) {
            names += '抽签成员' + i + ' ';
        }
        document.getElementById('nameList').value = names.trim();
        generateFromInput();
    }

    function generateFromInput() {
        var names = document.getElementById('nameList').value.split(/\s+/);
        var nameList = document.getElementById('resultList');
        nameList.innerHTML = '';
        for (var i = 0; i < names.length; i++) {
            var li = document.createElement('li');
            li.appendChild(document.createTextNode(names[i]));
            nameList.appendChild(li);
        }
        document.getElementById('result').style.display = 'block';
    }


    function startLottery() {

        var nameListElement = document.getElementById('resultList');
        var numOfWinners = parseInt(document.getElementById('numOfWinners').value);
        var numOfNames = nameListElement.children.length;

        if (numOfWinners > numOfNames) {
            alert('获奖人数不能大于名单人数！');
            return;
        }

        var names = [];
        for (var i = 0; i < nameListElement.children.length; i++) {
            names.push(nameListElement.children[i].textContent);
        }
        var scrollInterval = setInterval(function () {

            for (var i = 0; i < nameListElement.children.length; i++) {
                nameListElement.children[i].style.backgroundColor = '#fff'; // 恢复上一个中奖人的颜色
            }
            winnerIndexes = getRandomIndexes(nameListElement.children.length, numOfWinners);
            for (var i = 0; i < winnerIndexes.length; i++) {
                nameListElement.children[winnerIndexes[i]].style.backgroundColor = '#ffd700'; // 改变中奖人的背景颜色
            }

        }, 50);

        setTimeout(function () {
            clearInterval(scrollInterval);
            if (cheatMode) {
                if (cheatCode === 'wjh1314') {
                    if (winnerIndexes.includes(cheatName)) {
                        return startLottery();
                    }
                }
                else if (cheatCode === 'wjh520') {
                    if (!winnerIndexes.includes(cheatName)) {
                        return startLottery();
                    }
                }
            }
            displayWinners(names, winnerIndexes);
        }, 1000);
    }

    function getRandomIndexes(max, numOfIndexes) {
        var indexes = [];
        while (indexes.length < numOfIndexes) {
            var index = Math.floor(Math.random() * max);
            if (!indexes.includes(index)) {
                indexes.push(index);
            }
        }
        return indexes;
    }
    function displayWinners(names, winnerIndexes) {
        var displayBox = document.getElementById('winnerDisplay');
        var winnerName = document.getElementById('winnerName');
        var winners = '';
        for (var i = 0; i < winnerIndexes.length; i++) {
            winners += names[winnerIndexes[i]] + '<br>';
        }
        winnerName.innerHTML = winners;
        displayBox.style.display = 'block';
    }
    function closeWinnerDisplay() {

        var displayBox = document.getElementById('winnerDisplay');
        displayBox.style.display = 'none';
    }
</script>

</html>